<html>
<head><meta charset="utf-8"><title>lifetime inference and yield · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html">lifetime inference and yield</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="158031364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158031364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158031364">(Feb 11 2019 at 13:53)</a>:</h4>
<p>A user posted an issue in which the lifetime of a reference was unnecessarily inferred to include a yield point. Since this can impact the auto traits of the resulting state machine, it'd be ideal if this didn't happen. I was just wondering if anyone is thinking about how yield points interact with region inference. <a href="https://internals.rust-lang.org/t/async-await-and-references-in-pattern-match/9409/2" target="_blank" title="https://internals.rust-lang.org/t/async-await-and-references-in-pattern-match/9409/2">https://internals.rust-lang.org/t/async-await-and-references-in-pattern-match/9409/2</a></p>
<p>Also this is my first time using Zulip so sorry if I've not done things properly somehow. :))</p>



<a name="158031372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158031372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158031372">(Feb 11 2019 at 13:53)</a>:</h4>
<p>cc <span class="user-group-mention" data-user-group-id="491">@WG-compiler-nll</span></p>



<a name="158031980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158031980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158031980">(Feb 11 2019 at 14:02)</a>:</h4>
<p>hmm there's definitely something funny happening there</p>



<a name="158032105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032105">(Feb 11 2019 at 14:04)</a>:</h4>
<p>I want to double-check something: Is the claim here that this issue arises with and without AST-borrowck (which is non-trivial to check since one cannot run this example on the 2015 edition)?</p>



<a name="158032126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032126">(Feb 11 2019 at 14:04)</a>:</h4>
<p>and that the reason NLL is relevant is because one might hope that the increased precision of NLL would allow sidestepping the problem?</p>



<a name="158032164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032164">(Feb 11 2019 at 14:05)</a>:</h4>
<p>Or is the claim that this code works with AST-borrowck and NLL is somehow regressing it?</p>



<a name="158032176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032176">(Feb 11 2019 at 14:05)</a>:</h4>
<p><span class="user-mention" data-user-id="203289">@boats</span> ^ ?</p>



<a name="158032321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032321">(Feb 11 2019 at 14:07)</a>:</h4>
<p>I haven't investigated closely, but I don't have any reason to think its a regression.</p>



<a name="158032425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032425">(Feb 11 2019 at 14:08)</a>:</h4>
<p>I find it fascinating that pulling the <code>f.foo()</code> expression out into its own local sidesteps the error. I'm more used to things going in the other direction. <span aria-label="smiley" class="emoji emoji-1f603" role="img" title="smiley">:smiley:</span></p>



<a name="158032474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032474">(Feb 11 2019 at 14:09)</a>:</h4>
<p>(except of course for the cases where pulling it into a local is also introducing changes to evaluation order. But I do not think that is happening here. Then again I might be misunderstanding the generator desugaring.)</p>



<a name="158032476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032476">(Feb 11 2019 at 14:09)</a>:</h4>
<p>Yea it was very surprising to me also that that code change made it compile.</p>



<a name="158032729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> boats <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032729">(Feb 11 2019 at 14:13)</a>:</h4>
<p>The most interesting thing to me in this thread was that this is a design goal that could be factored into future NLL/polonius work - reducing the number of live objects across yield points. This matters both for auto traits like in this example and also optimizing the size of the state machine.</p>



<a name="158032938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/lifetime%20inference%20and%20yield/near/158032938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/lifetime.20inference.20and.20yield.html#158032938">(Feb 11 2019 at 14:16)</a>:</h4>
<p>definitely</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>